<?php
session_start();

include "webmaster_connect.php";

$page_permission = 2;

include "webmaster_check_login.php";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style type="text/css">
body {
	background-image: url(../images/wood.jpg);
	background-repeat: repeat-x;
	margin: 0px;
	background-position: left top;
	background-attachment: fixed;
	background-color: #000000;
	padding-top: 0px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 0px;
}
</style>
<link href="../css/webmaster_view_sell_requests.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div id="page_container">

<?php 

include "../admin_files/webmaster_header.php";
include "../admin_files/webmaster_navigation.php" 

?>

<div id="content_container">


<h1>Edit products:</h1>

<form id="product_filter" action="webmaster_view_sell_requests.php" method="post" name="request_filter">

<label> Status: 
<select name="request_status">
<option value="New">New</option>
<option value="Read">Read</option>
<option value="All">All</option>
</select>
</label>

<input name="request" type="submit" value="Refresh" id="button"/>

</form>

<table width="970px" border="0" cellpadding="3">

<tr>
    <th class="header" scope="col"></th>
    <th class="header" scope="col">Status</th>
    <th class="header" scope="col">Request Date</th>
    <th class="header" scope="col">Customer Name</th>
    <th class="header" scope="col">Sell Type</th>
    <th class="header" scope="col">Estimate Price</th>
  </tr>

<?php 

$request_status = $_POST['request_status'];

$query = "SELECT * FROM customer_sell_requests";


//On first load of the page display NEW requests only
if(!isset($_POST['request_status'])){$query .= " WHERE request_status = 'New'";}

//If filter is changed
if(isset($_POST['request_status'])) //If status is posted then do below checks

{

	if ($request_status != "All") //If filter selected is NOT "All"

	{
		$query .= " WHERE request_status = '$request_status'";
	}
	
}

$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
	
//Format request date
$request_date = $row['request_date'];
$request_date = date("d/m/Y", strtotime($request_date));
//End
	
echo '

  <tr>
  
    <th>
		<form action="webmaster_sell_request.php" method="post" name="view_request">
		<input name="request_id" type="hidden" value="'.$row['request_id'].'" />
		<input name="view_request" type="submit" value="View" id="button"/>
		</form>
	</th>
	
	<th>'.$row['request_status'].'</th>
    <th>'.$request_date.'</th>
    <th>'.$row['customer_name'].'</th>
    <th>'.$row['sell_type'].'</th>
	<th>£'.$row['estimate_price'].'</th>
  </tr>

';
	
}


?>

</table>

<?php  //echo $query ?>

</div>
<!--login_container-->

</div> 
<!--page_container-->

</body>
</html>

